// 蜂窝蜜造平台生成代码，如手工更改，请添加到 .beeignore 忽略生成
package com.fowo.api.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fowo.api.common.model.IdListPo;
import com.fowo.api.common.model.IdPo;
import com.fowo.api.common.model.ImportRow;
import com.fowo.api.common.model.OptionItem;
import com.fowo.api.common.model.R;
import com.fowo.api.common.util.ResponseUtils;
import com.fowo.api.entity.NavSellOrder;
import com.fowo.api.model.nav.sell.order.NavSellOrderGetInventoryParam;
import com.fowo.api.model.nav.sell.order.NavSellOrderGetInventoryResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderImportPo;
import com.fowo.api.model.nav.sell.order.NavSellOrderItemVo;
import com.fowo.api.model.nav.sell.order.NavSellOrderSearchParamPo;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectCostPriceParam;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectCostPriceResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectJoinOrderResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectNoPariOrderIdListParam;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectNoPariOrderIdListResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectPariListParam;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectPariListResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectPrintDetailParam;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectPrintDetailResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectPrintParam;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectPrintResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectProductParam;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectProductResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectSplitOrderResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderSelectTagCountResult;
import com.fowo.api.model.nav.sell.order.NavSellOrderVo;
import com.fowo.api.service.NavSellOrderService;
import com.fowo.api.sys.entity.SysFile;
import com.fowo.api.user.model.JwtUserInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.core.io.ClassPathResource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StreamUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "订单管理")
@RequestMapping("/api/nav-sell-order")
@RestController
public class NavSellOrderController {

  @Resource
  private NavSellOrderService service;

  @Operation(summary = "查询结果")
  @GetMapping
  public R<List<NavSellOrderItemVo>> search(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.search(search));
  }

  @Operation(summary = "快速查询选项(有缓存)")
  @GetMapping("options")
  public R<List<OptionItem<NavSellOrderItemVo>>> searchOptions(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.searchOptions(search));
  }

  @Operation(summary = "查询最后更新时间")
  @GetMapping("lastUpdateTime")
  public R<Date> searchLastUpdateTime(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.searchLastUpdateTime(search));
  }

  @Operation(summary = "获取分页查询结果")
  @GetMapping("page")
  public R<Page<NavSellOrderItemVo>> getPage(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageSearch(search));
  }

  @Operation(summary = "获取包括子表的查询结果")
  @GetMapping("page-with-child")
  public R<Page<?>> getPageWithChild(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageWithChildSearch(search));
  }

  @Operation(summary = "仅获取子表的查询结果")
  @GetMapping("page-only-child/{parentId}")
  public R<Page<?>> getPageOnlyChild(
    @PathVariable Long parentId,
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pageOnlyChildSearch(parentId, search));
  }

  @Operation(summary = "查询是否后台下载")
  @GetMapping("getBackgroundExportFlag")
  public R<Boolean> getBackgroundExportFlag(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.getBackgroundExportFlag(search));
  }

  @Operation(summary = "获取详情")
  @GetMapping("{id}")
  public R<NavSellOrderVo> getVoById(@PathVariable Long id) {
    return R.data(() -> service.getVoById(id));
  }

  @Operation(summary = "获取系统单号相关的编号列表")
  @GetMapping("order-id/{texts}/ids")
  public R<List<Long>> getIdsByOrderId(@PathVariable String texts) {
    List<String> nameList = Arrays
      .stream(texts.split(","))
      .collect(Collectors.toList());
    return R.data(() -> service.getIdsByOrderId(nameList));
  }

  @Operation(summary = "获取编号相关的系统单号列表")
  @GetMapping("order-id/{ids}")
  public R<List<String>> getVoById(@PathVariable String ids) {
    List<Long> idList = Arrays
      .asList(ids.split(","))
      .stream()
      .map(Long::valueOf)
      .collect(Collectors.toList());
    return R.data(() -> service.getOrderIdByIds(idList));
  }

  @PreAuthorize("@am.canAccess('navSellOrderCreate')")
  @Operation(summary = "新增")
  @PostMapping
  public R<Long> create(@Validated @RequestBody NavSellOrderVo model) {
    return R.data(() -> service.create(model));
  }

  @PreAuthorize("@am.canAccess('navSellOrderEdit')")
  @Operation(summary = "更新")
  @PutMapping
  public R update(@RequestBody NavSellOrderVo model) {
    return R.run(() -> service.update(model));
  }

  @PreAuthorize("@am.canAccess('navSellOrderEdit')")
  @Operation(summary = "编辑更新")
  @PutMapping("edit")
  public R updateForEdit(@RequestBody NavSellOrderVo model) {
    return R.run(() -> service.updateForEdit(model));
  }

  @PreAuthorize("@am.canAccess('navSellOrderDelete')")
  @Operation(summary = "删除")
  @DeleteMapping("{id}")
  public R delete(@PathVariable Long id) {
    return R.run(() -> service.delete(id));
  }

  @PreAuthorize("@am.canAccess('navSellOrderDelete')")
  @Operation(summary = "批量删除")
  @DeleteMapping("batch")
  public R batchDelete(@RequestBody IdListPo po) {
    return R.run(() -> service.batchDelete(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderImport')")
  @Operation(summary = "导入预览")
  @PostMapping("import-preview")
  public R<List<ImportRow<NavSellOrderImportPo>>> importPreview(
    @RequestBody SysFile sysFile,
    @RequestParam(name = "template", required = false) Long templateId,
    @RequestParam(
      name = "allowOverrides",
      defaultValue = "false"
    ) boolean allowOverrides
  ) {
    return R.data(() ->
      service.importPreview(sysFile, templateId, allowOverrides)
    );
  }

  @PreAuthorize("@am.canAccess('navSellOrderImport')")
  @Operation(summary = "完成导入")
  @PostMapping("import-done")
  public R importDone(
    @RequestBody List<ImportRow<NavSellOrderImportPo>> rows,
    @RequestParam(name = "template", required = false) Long templateId
  ) {
    return R.run(() -> service.importDone(rows, templateId));
  }

  @Operation(summary = "下载导入模版")
  @GetMapping("import/template")
  public void downloadImportTemplate(HttpServletResponse response)
    throws IOException {
    ResponseUtils.setAttachmentFileName(response, "订单管理导入模版.xlsx");
    InputStream inputStream = new ClassPathResource(
      "templates/NavSellOrder.xlsx"
    )
      .getInputStream();
    StreamUtils.copy(inputStream, response.getOutputStream());
  }

  @Operation(summary = "导出")
  @GetMapping("export")
  @PreAuthorize("@am.canAccess('navSellOrderExport')")
  public void export(
    @RequestParam(name = "template", required = false) Long templateId,
    NavSellOrderSearchParamPo search,
    HttpServletResponse response
  ) throws Exception {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    service.export(templateId, search, response);
  }

  @PreAuthorize("@am.canAccess('navSellOrderProcess')")
  @Operation(summary = "审核")
  @PostMapping("process")
  public R process(@RequestBody IdListPo po) {
    return R.run(() -> service.process(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderDeliver')")
  @Operation(summary = "发货")
  @PostMapping("deliver")
  public R deliver(@RequestBody IdListPo po) {
    return R.run(() -> service.deliver(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderCut')")
  @Operation(summary = "截单")
  @PostMapping("cut")
  public R cut(@RequestBody IdListPo po) {
    return R.run(() -> service.cut(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderCreatePurchase')")
  @Operation(summary = "生成采购单")
  @PostMapping("createPurchase")
  public R createPurchase(@RequestBody IdListPo po) {
    return R.run(() -> service.createPurchase(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderJoinTask')")
  @Operation(summary = "合并检查")
  @PostMapping("joinTask")
  public R joinTask() {
    return R.run(() -> service.joinTask());
  }

  @PreAuthorize("@am.canAccess('navSellOrderSplitTask')")
  @Operation(summary = "拆分检查")
  @PostMapping("splitTask")
  public R splitTask() {
    return R.run(() -> service.splitTask());
  }

  @PreAuthorize("@am.canAccess('navSellOrderDeclareToProduct')")
  @Operation(summary = "更新报关信息")
  @PostMapping("declareToProduct")
  public R declareToProduct(@RequestBody IdPo po) {
    return R.run(() -> service.declareToProduct(po.getId()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderNoDeliver')")
  @Operation(summary = "不发货")
  @PostMapping("noDeliver")
  public R noDeliver(@RequestBody IdListPo po) {
    return R.run(() -> service.noDeliver(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderFreeze')")
  @Operation(summary = "冻结")
  @PostMapping("freeze")
  public R freeze(@RequestBody IdListPo po) {
    return R.run(() -> service.freeze(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderUnFreeze')")
  @Operation(summary = "取消冻结")
  @PostMapping("unFreeze")
  public R unFreeze(@RequestBody IdListPo po) {
    return R.run(() -> service.unFreeze(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderChangeTag')")
  @Operation(summary = "标记标签")
  @PostMapping("changeTag")
  public R changeTag(@RequestBody IdListPo po) {
    return R.run(() -> service.changeTag(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderJoin')")
  @Operation(summary = "合并")
  @PostMapping("join")
  public R join(@RequestBody IdListPo po) {
    return R.run(() -> service.join(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderLeaveMessageProcessed')")
  @Operation(summary = "留言已处理")
  @PostMapping("leaveMessageProcessed")
  public R leaveMessageProcessed(@RequestBody IdListPo po) {
    return R.run(() -> service.leaveMessageProcessed(po.getIds()));
  }

  @PreAuthorize("@am.canAccess('navSellOrderPickingDeliver')")
  @Operation(summary = "发货")
  @PostMapping("pickingDeliver")
  public R pickingDeliver(@RequestBody IdListPo po) {
    return R.run(() -> service.pickingDeliver(po.getIds()));
  }

  /**
   * 视图选项卡标题上显示计数
   */
  @Operation(summary = "视图选项卡标题上显示计数")
  @GetMapping("getTabHeaderShowTotal")
  public R<Map> getTabHeaderShowTotal() {
    return R.data(() -> service.getTabHeaderShowTotal());
  }

  @Operation(summary = "全部")
  @GetMapping("all-order")
  public R<List<NavSellOrderItemVo>> allOrder(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.allOrder(search));
  }

  @Operation(summary = "全部分页")
  @GetMapping("all-orderPage")
  public R<Page<NavSellOrderItemVo>> allOrderPage(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.allOrderPage(search));
  }

  @Operation(summary = "全部包括子表的查询结果")
  @GetMapping("all-orderPage-with-child")
  public R<Page<?>> allOrderPageWithChild(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.allOrderPageWithChildSearch(search));
  }

  @Operation(summary = "全部最后更新时间")
  @GetMapping("all-orderLastUpdateTime")
  public R<Date> allOrderLastUpdateTime(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.allOrderLastUpdateTime(search));
  }

  @Operation(summary = "待审核")
  @GetMapping("pending-audit-order")
  public R<List<NavSellOrderItemVo>> pendingAuditOrder(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.pendingAuditOrder(search));
  }

  @Operation(summary = "待审核分页")
  @GetMapping("pending-audit-orderPage")
  public R<Page<NavSellOrderItemVo>> pendingAuditOrderPage(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.pendingAuditOrderPage(search));
  }

  @Operation(summary = "待审核包括子表的查询结果")
  @GetMapping("pending-audit-orderPage-with-child")
  public R<Page<?>> pendingAuditOrderPageWithChild(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pendingAuditOrderPageWithChildSearch(search));
  }

  @Operation(summary = "待审核最后更新时间")
  @GetMapping("pending-audit-orderLastUpdateTime")
  public R<Date> pendingAuditOrderLastUpdateTime(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.pendingAuditOrderLastUpdateTime(search));
  }

  @Operation(summary = "待发货")
  @GetMapping("pending-deliver-order")
  public R<List<NavSellOrderItemVo>> pendingDeliverOrder(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.pendingDeliverOrder(search));
  }

  @Operation(summary = "待发货分页")
  @GetMapping("pending-deliver-orderPage")
  public R<Page<NavSellOrderItemVo>> pendingDeliverOrderPage(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.pendingDeliverOrderPage(search));
  }

  @Operation(summary = "待发货包括子表的查询结果")
  @GetMapping("pending-deliver-orderPage-with-child")
  public R<Page<?>> pendingDeliverOrderPageWithChild(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.pendingDeliverOrderPageWithChildSearch(search));
  }

  @Operation(summary = "待发货最后更新时间")
  @GetMapping("pending-deliver-orderLastUpdateTime")
  public R<Date> pendingDeliverOrderLastUpdateTime(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.pendingDeliverOrderLastUpdateTime(search));
  }

  @Operation(summary = "已发货")
  @GetMapping("deliver-order")
  public R<List<NavSellOrderItemVo>> deliverOrder(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.deliverOrder(search));
  }

  @Operation(summary = "已发货分页")
  @GetMapping("deliver-orderPage")
  public R<Page<NavSellOrderItemVo>> deliverOrderPage(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.deliverOrderPage(search));
  }

  @Operation(summary = "已发货包括子表的查询结果")
  @GetMapping("deliver-orderPage-with-child")
  public R<Page<?>> deliverOrderPageWithChild(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.deliverOrderPageWithChildSearch(search));
  }

  @Operation(summary = "已发货最后更新时间")
  @GetMapping("deliver-orderLastUpdateTime")
  public R<Date> deliverOrderLastUpdateTime(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.deliverOrderLastUpdateTime(search));
  }

  @Operation(summary = "不发货")
  @GetMapping("no-deliver-order")
  public R<List<NavSellOrderItemVo>> noDeliverOrder(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.noDeliverOrder(search));
  }

  @Operation(summary = "不发货分页")
  @GetMapping("no-deliver-orderPage")
  public R<Page<NavSellOrderItemVo>> noDeliverOrderPage(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.noDeliverOrderPage(search));
  }

  @Operation(summary = "不发货包括子表的查询结果")
  @GetMapping("no-deliver-orderPage-with-child")
  public R<Page<?>> noDeliverOrderPageWithChild(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.noDeliverOrderPageWithChildSearch(search));
  }

  @Operation(summary = "不发货最后更新时间")
  @GetMapping("no-deliver-orderLastUpdateTime")
  public R<Date> noDeliverOrderLastUpdateTime(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.noDeliverOrderLastUpdateTime(search));
  }

  @Operation(summary = "平台发货")
  @GetMapping("platform-deliver-order")
  public R<List<NavSellOrderItemVo>> platformDeliverOrder(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.platformDeliverOrder(search));
  }

  @Operation(summary = "平台发货分页")
  @GetMapping("platform-deliver-orderPage")
  public R<Page<NavSellOrderItemVo>> platformDeliverOrderPage(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.platformDeliverOrderPage(search));
  }

  @Operation(summary = "平台发货包括子表的查询结果")
  @GetMapping("platform-deliver-orderPage-with-child")
  public R<Page<?>> platformDeliverOrderPageWithChild(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.platformDeliverOrderPageWithChildSearch(search));
  }

  @Operation(summary = "平台发货最后更新时间")
  @GetMapping("platform-deliver-orderLastUpdateTime")
  public R<Date> platformDeliverOrderLastUpdateTime(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.platformDeliverOrderLastUpdateTime(search));
  }

  @Operation(summary = "可合并订单")
  @GetMapping("can-join-order")
  public R<List<NavSellOrderItemVo>> canJoinOrder(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.canJoinOrder(search));
  }

  @Operation(summary = "可合并订单分页")
  @GetMapping("can-join-orderPage")
  public R<Page<NavSellOrderItemVo>> canJoinOrderPage(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.canJoinOrderPage(search));
  }

  @Operation(summary = "可合并订单包括子表的查询结果")
  @GetMapping("can-join-orderPage-with-child")
  public R<Page<?>> canJoinOrderPageWithChild(
    NavSellOrderSearchParamPo search
  ) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(service.canJoinOrderPageWithChildSearch(search));
  }

  @Operation(summary = "可合并订单最后更新时间")
  @GetMapping("can-join-orderLastUpdateTime")
  public R<Date> canJoinOrderLastUpdateTime(NavSellOrderSearchParamPo search) {
    JwtUserInfo jwtUserInfo = JwtUserInfo.fromHeader();
    if (jwtUserInfo != null) {
      search.setCurrentUserId(jwtUserInfo.getUserId());
    }
    return R.data(() -> service.canJoinOrderLastUpdateTime(search));
  }

  @Operation(summary = "查询合并订单")
  @GetMapping("getSelectJoinOrder")
  public R<Page<NavSellOrderSelectJoinOrderResult>> selectJoinOrder(
    NavSellOrderSearchParamPo param
  ) {
    return R.data(() -> service.selectJoinOrder(param));
  }

  @Operation(summary = "查询拆分订单")
  @GetMapping("selectSplitOrder")
  public R<Page<NavSellOrderSelectSplitOrderResult>> selectSplitOrder(
    NavSellOrderSearchParamPo param
  ) {
    return R.data(() -> service.selectSplitOrder(param));
  }

  @Operation(summary = "库存预览")
  @GetMapping("getInventory")
  public R<Page<NavSellOrderGetInventoryResult>> getInventory(
    NavSellOrderGetInventoryParam param
  ) {
    return R.data(() -> service.getInventory(param));
  }

  @Operation(summary = "获取打单,面单,发货单打印主表信息")
  @GetMapping("GetPrint")
  public R<List<NavSellOrderSelectPrintResult>> selectPrint(
    NavSellOrderSelectPrintParam param
  ) {
    return R.data(() -> service.selectPrint(param));
  }

  @Operation(summary = "获取打单,面单,发货单打印详情信息")
  @GetMapping("GetPrintDetail")
  public R<List<NavSellOrderSelectPrintDetailResult>> selectPrintDetail(
    NavSellOrderSelectPrintDetailParam param
  ) {
    return R.data(() -> service.selectPrintDetail(param));
  }

  @Operation(summary = "获取标签数量")
  @GetMapping("SelectTagCount")
  public R<Page<NavSellOrderSelectTagCountResult>> selectTagCount(
    NavSellOrderSearchParamPo param
  ) {
    return R.data(() -> service.selectTagCount(param));
  }

  @Operation(summary = "换货")
  @GetMapping("selectPariList")
  public R<Page<NavSellOrderSelectPariListResult>> selectPariList(
    NavSellOrderSelectPariListParam param
  ) {
    return R.data(() -> service.selectPariList(param));
  }

  @Operation(summary = "配对")
  @GetMapping("selectProduct")
  public R<Page<NavSellOrderSelectProductResult>> selectProduct(
    NavSellOrderSelectProductParam param
  ) {
    return R.data(() -> service.selectProduct(param));
  }

  @Operation(summary = "根据msku查询未配对列表")
  @GetMapping("selectNoPariOrderIdList")
  public R<List<NavSellOrderSelectNoPariOrderIdListResult>> selectNoPariOrderIdList(
    NavSellOrderSelectNoPariOrderIdListParam param
  ) {
    return R.data(() -> service.selectNoPariOrderIdList(param));
  }

  @Operation(summary = "查询预估出库成本")
  @GetMapping("selectCostPrice")
  public R<List<NavSellOrderSelectCostPriceResult>> selectCostPrice(
    NavSellOrderSelectCostPriceParam param
  ) {
    return R.data(() -> service.selectCostPrice(param));
  }
}
